package com.sky.mapper;


import com.sky.entity.AddressBook;
import com.sky.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RessBookMapper {
/*
* 添加地址
* */
    @Insert("insert into address_book(user_id, consignee, sex, phone, province_code, province_name, city_code, city_name, district_code, district_name, detail, label, is_default) VALUES " +
            "(#{userId},#{consignee},#{sex},#{phone},#{provinceCode},#{provinceName},#{cityCode},#{cityName},#{districtCode},#{districtName},#{detail},#{label},#{isDefault})")
    void addBook(AddressBook addressBook);
/*
* 查询地址
* */
    List<AddressBook> list(AddressBook addressBook);
/*
* 根据id查询
* */
    @Select("select * from address_book where id=#{id}")
    AddressBook listBid(long id);
/*
* 修改地址
* */
    void update(AddressBook addressBook);
/*
* 根据id删除地址
* */
    @Delete("delete from address_book where id=#{id}")
    void deleteByid(long id);
/*
* 根据userid修改所有默认地址为0
* */
    @Update("update address_book set is_default=#{isDefault} where user_id=#{userId}")
    void updateByUid(AddressBook addressBook);
}
